package com.study.happystudy.service.impl;

import com.study.happystudy.entity.ResultEntity;
import com.study.happystudy.service.AiService;
import com.study.happystudy.tool.Translators;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.logging.Logger;

@Service
public class AiServiceImpl implements AiService {
    @Resource
    Translators translators ;

    @Override
    public String AITranslate(String SourceLanguage, String TargetLanguage, String SourceText) {
        try {
            String result = translators.translate(SourceLanguage, TargetLanguage, SourceText);
            return ResultEntity.Success(0,result);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultEntity.Fail(-1,"文本翻译失败!");//返回错误代码
        }
    }
}
